package cn.tedu.logistics.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import cn.tedu.logistics.bean.Purview;
@Mapper
public interface PurviewDao extends BaseMapper<Purview>{
	@Select("select p.*,m.admin from tb_purviews p join tb_manager m on p.id=m.id group by id")
	public List<Purview> readPurview();
	@Update("		update tb_purviews set sysset=#{sysset},readerset=#{readerset}\n" + 
			"		,bookset=#{bookset},borrowback=#{borrowback},sysquery=#{sysquery}\n" + 
			"		where\n" + 
			"		id=#{id}")
	public int updatePurview(Purview purview);
	/**
	 * 根据ID删除该管理员
	 */
//	public int deleteById(Integer id);
	/**
	 * 根据Id查询权限
	 */
	@Select("select * from tb_purviews where id=#{id}")
	public Purview PurviewById(Integer id);
	@Insert("insert  into tb_manager(admin,PWD) value (#{username},#{md5password})")
    int addManager(@Param("username") String username,@Param("md5password") String md5password);
	@Insert("INSERT INTO tb_purviews(sysset,readerset,bookset,borrowback,sysquery) VALUE('1','1','1','1','1')")
	void addPurviews();
}
